package agriculture.controller;

import agriculture.bean.Category;
import agriculture.service.CategoryService;
import agriculture.util.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CategoryController {
    private final CategoryService categoryService;

    public CategoryController(CategoryService categoryService) {
        this.categoryService = categoryService;
    }

    /**
     * 获取一级分类的查询
     */
    @GetMapping("/list")
    public Result listCategories() {
        List<Category> categories = categoryService.getAllCategories();
        return new Result(200, "查询成功", categories);
    }
}
